/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Amazon.ECS;
using Amazon.ECS.Model;

namespace Amazon.ECS.Samples
{

    /// <summary>
    /// Help  Samples
    /// </summary>
    public class HelpSample
    {
    
                         
        /// <summary>
        /// 
        /// <p/>
        /// The Help operation provides information about ECS operations and
        /// response groups. For operations, Help lists required and optional
        /// request parameters, as well as default and optional response groups the
        /// operation can use. For response groups, Help lists the operations that can
        /// use the response group as well as the response tags returned by the
        /// response group in the XML response.
        /// <p/>
        /// The Help operation is not often used in customer applications. It can, however, be
        /// used to help the developer in the following ways:
        /// <p/>
        /// <ul>
        /// <li>Provide contextual help in an interactive development environment (IDE) for developerst</li>
        /// <li>Automate documentation creation as part of a developer's toolkit. </li>
        /// </ul>
        /// <p/>
        /// <b>Available Response Groups</b>:
        /// <ul>
        /// <li>Request</li>
        /// <li>Help</li>
        /// </ul>
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonECS service</param>
        /// <param name="request">Help request</param>
        public static void InvokeHelp(AmazonECS service, params HelpRequest [] request) 
        {
            try 
            {
                HelpResponse response = service.Help(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        HelpResponse");
                if (response.IsSetOperationRequest()) 
                {
                    Console.WriteLine("            OperationRequest");
                    OperationRequest  operationRequest = response.OperationRequest;
                    if (operationRequest.IsSetHTTPHeaders()) 
                    {
                        Console.WriteLine("                HTTPHeaders");
                        HTTPHeaders  HTTPHeaders = operationRequest.HTTPHeaders;
                    } 
                    if (operationRequest.IsSetRequestId()) 
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", operationRequest.RequestId);
                    }
                    if (operationRequest.IsSetArguments()) 
                    {
                        Console.WriteLine("                Arguments");
                        Arguments  arguments = operationRequest.Arguments;
                    } 
                    if (operationRequest.IsSetRequestProcessingTime()) 
                    {
                        Console.WriteLine("                RequestProcessingTime");
                        Console.WriteLine("                    {0}", operationRequest.RequestProcessingTime);
                    }
                } 
                List<Information> informationList = response.Information;
                foreach (Information information in informationList) 
                {
                    Console.WriteLine("            Information");
                    List<OperationInformation> operationInformationList = information.OperationInformation;
                    foreach (OperationInformation operationInformation in operationInformationList) 
                    {
                        Console.WriteLine("                OperationInformation");
                        if (operationInformation.IsSetName()) 
                        {
                            Console.WriteLine("                    Name");
                            Console.WriteLine("                        {0}", operationInformation.Name);
                        }
                        if (operationInformation.IsSetDescription()) 
                        {
                            Console.WriteLine("                    Description");
                            Console.WriteLine("                        {0}", operationInformation.Description);
                        }
                        if (operationInformation.IsSetRequiredParameters()) 
                        {
                            Console.WriteLine("                    RequiredParameters");
                            RequiredParameters  requiredParameters = operationInformation.RequiredParameters;
                            List<String> parameterList  =  requiredParameters.Parameter;
                            foreach (String parameter in parameterList) 
                            { 
                                Console.WriteLine("                        Parameter");
                                Console.WriteLine("                            {0}", parameter);
                            }	
                        } 
                        if (operationInformation.IsSetAvailableParameters()) 
                        {
                            Console.WriteLine("                    AvailableParameters");
                            AvailableParameters  availableParameters = operationInformation.AvailableParameters;
                            List<String> parameterList  =  availableParameters.Parameter;
                            foreach (String parameter in parameterList) 
                            { 
                                Console.WriteLine("                        Parameter");
                                Console.WriteLine("                            {0}", parameter);
                            }	
                        } 
                        if (operationInformation.IsSetDefaultResponseGroups()) 
                        {
                            Console.WriteLine("                    DefaultResponseGroups");
                            DefaultResponseGroups  defaultResponseGroups = operationInformation.DefaultResponseGroups;
                            List<String> responseGroupList  =  defaultResponseGroups.ResponseGroup;
                            foreach (String responseGroup in responseGroupList) 
                            { 
                                Console.WriteLine("                        ResponseGroup");
                                Console.WriteLine("                            {0}", responseGroup);
                            }	
                        } 
                        if (operationInformation.IsSetAvailableResponseGroups()) 
                        {
                            Console.WriteLine("                    AvailableResponseGroups");
                            AvailableResponseGroups  availableResponseGroups = operationInformation.AvailableResponseGroups;
                            List<String> responseGroupList  =  availableResponseGroups.ResponseGroup;
                            foreach (String responseGroup in responseGroupList) 
                            { 
                                Console.WriteLine("                        ResponseGroup");
                                Console.WriteLine("                            {0}", responseGroup);
                            }	
                        } 
                    }
                    List<ResponseGroupInformation> responseGroupInformationList = information.ResponseGroupInformation;
                    foreach (ResponseGroupInformation responseGroupInformation in responseGroupInformationList) 
                    {
                        Console.WriteLine("                ResponseGroupInformation");
                        if (responseGroupInformation.IsSetName()) 
                        {
                            Console.WriteLine("                    Name");
                            Console.WriteLine("                        {0}", responseGroupInformation.Name);
                        }
                        if (responseGroupInformation.IsSetCreationDate()) 
                        {
                            Console.WriteLine("                    CreationDate");
                            Console.WriteLine("                        {0}", responseGroupInformation.CreationDate);
                        }
                        if (responseGroupInformation.IsSetValidOperations()) 
                        {
                            Console.WriteLine("                    ValidOperations");
                            ResponseGroupValidOperations  validOperations = responseGroupInformation.ValidOperations;
                            List<String> operationList  =  validOperations.Operation;
                            foreach (String operation in operationList) 
                            { 
                                Console.WriteLine("                        Operation");
                                Console.WriteLine("                            {0}", operation);
                            }	
                        } 
                        if (responseGroupInformation.IsSetElements()) 
                        {
                            Console.WriteLine("                    Elements");
                            ResponseGroupElements  elements = responseGroupInformation.Elements;
                            List<String> elementList  =  elements.Element;
                            foreach (String element in elementList) 
                            { 
                                Console.WriteLine("                        Element");
                                Console.WriteLine("                            {0}", element);
                            }	
                        } 
                    }
                }

            } 
            catch (AmazonECSException ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
                                                                                }
}
